#ifndef CELL_PARTITION_3D_H
#define CELL_PARTITION_3D_H

#include "Box3D.hpp"
#include "../objects/Object.hpp"
#include "../utils/Vector3D.hpp"
#include <vector>
#include <list>
#include <irrlicht.h>



namespace klasPhysics
{
	struct Cell
	{
		Box3D m_BBox;
		std::list<Object*> m_Objects;
		irr::scene::ISceneNode* RenderBox;

		Cell()
		{}

		Cell(Box3D bbox):m_BBox(bbox)
		{}
	};

	class CellSpacePartition3D
	{
	private:
		vector<Cell> m_CellArray;

		Vector3D m_Dimensions;
		Vector3D m_NumCells;
		Vector3D m_CellSize;

		int PositionToIndex(const Vector3D& pos)const;

	public:
		CellSpacePartition3D(Vector3D dim, Vector3D num_cells, int MaxEntities);
		
		void AddObject(Object* object);
		void UpdateEntity(Object* ent, Vector3D);

		list<Object*> CalculateCollisions(Vector3D TargetPos, Box3D CBox);
	
		void EmptyCells();

		// Temporary function, as this SDK will not include rendering capabilities
		void RenderCells(irr::scene::ISceneManager* s_mgr);
	};
}

#endif